﻿using leaf.Base;
using leaf.Entity;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace leaf.Controllers
{
    /// <summary>
    /// 连接D版HIS api 获取数据
    /// </summary>
    public class DataController : Controller
    {
        /// <summary>
        /// 获取服务器时间
        /// </summary>
        /// <returns></returns>
        public string GetServerDate()
        {
            string userId = "";
            string sxml =
               @"?SXml=" +
                "<Request>" +
                "<TransCode>1001</TransCode> " +
                "<UserId>" + userId + "</UserId>" +
                "</Request>";
            string uri = BaseSupport.GetConfig("his_server_uri") + "/DYSoft.WebService_S.asmx/QueryHISTime" + sxml;
            var rsp = HttpSay.Get<ServerDate>(uri);
            return JsonConvert.SerializeObject(rsp);
        }

        /// <summary>
        /// 获取检验列表
        /// </summary>
        /// <returns></returns>
        public string GetServerJYList()
        {
            string cardTypeId = "";
            string cardNo = "";
            string patientId = "";
            string userId = "";

            string sxml =
               @"?SXml=" +
                "<Request>" +
                "<TransCode>6001</TransCode>" +
                "<CardTypeID>" + cardTypeId + "</CardTypeID>" +
                "<CardNo>" + cardNo + "</CardNo>" +
                "<PatientID>" + patientId + "</PatientID>" +
                "<UserId>" + userId + "</UserId>" +
                "</Request>";
            string uri = BaseSupport.GetConfig("his_server_uri") + "/DYSoft.WebService_S.asmx/QueryLaboratoryRecordList" + sxml;
            var rsp = HttpSay.Get<ServerCostList>(uri);
            return JsonConvert.SerializeObject(rsp);
        }

        /// <summary>
        ///获取检验详细信息
        /// </summary>
        /// <returns></returns>
        public string GetServerJYReport()
        {
            string inReportID = "";
            string inReportClass = "";
            string userId = "";

            string sxml =
              @"?SXml=" +
               "<Request>" +
               "<TransCode>6002</TransCode>" +
               "<inReportID>" + inReportID + "</inReportID>" +
               "<inReportClass>" + inReportClass + "</inReportClass>" +
               "<UserId>" + userId + "</UserId>" +
               "</Request>";
            string uri = BaseSupport.GetConfig("his_server_uri") + "/DYSoft.WebService_S.asmx/QueryLaboratoryDetail" + sxml;
            var rsp = HttpSay.Get<ServerJYReport>(uri);
            return JsonConvert.SerializeObject(rsp);
        }

        /// <summary>
        /// 获取检查详细信息
        /// </summary>
        /// <returns></returns>
        public string GetServerJCList()
        {
            return "";
        }

        /// <summary>
        /// 获取检查列表
        /// </summary>
        /// <returns></returns>
        public string GetServerJCReport()
        {
            return "";
        }

        /// <summary>
        /// 获取费用清单
        /// </summary>
        /// <returns></returns>
        public string GetCostList()
        {
            string recipeDate = "";
            string recipeSEQ = "";
            string userId = "";

            string sxml =
               @"?SXml=" +
                "<Request>" +
                "<TransCode>4003</TransCode>" +
                "<RecipeDate>" + recipeDate + "</RecipeDate>" +
                "<RecipeSEQ>" + recipeSEQ + "</RecipeSEQ>" +
                "<UserId>" + userId + "</UserId>" +
                "</Request>";
            string uri = BaseSupport.GetConfig("his_server_uri") + "/DYSoft.WebService_S.asmx/QueryToPayDetail" + sxml;
            var rsp = HttpSay.Get<ServerDate>(uri);
            return JsonConvert.SerializeObject(rsp);
        }
    }
}